<?php
namespace app\forms\exceptions;
class LoginFailedException extends \LogicException {
	const USER_NOT_EXIST = 1;
	const PASSWORD_NOT_MATCH = 2;
	
	static $errorMap = [
		self::USER_NOT_EXIST => '用户不存在',
		self::PASSWORD_NOT_MATCH => '密码不正确',
	];
	
	public function __construct($code){
		if (!isset(self::$errorMap[$code])) {
			throw new \RuntimeException('无法找到此错误对应的消息');
		}
		
		parent::__construct(self::$errorMap[$code], $code);
	}
}